package event;

import observer.ObservedList;
import observer.Copiable;

/**
 * This is for events in which an element is moved within an {@link ObservedList}.
 *
 * @author Neil Dickson
 */
public class ListMoveEvent<E extends Copiable> implements Undoable {
	private	ObservedList<E>	list;
	private	int				from;
	private	int				to;

	public ListMoveEvent(ObservedList<E> list,int from,int to) {
		this.list = list;
		this.from = from;
		this.to = to;
	}

	public Undoable undo() {
		list.move(to,from);
		// FIXME: Move the view to the location of the changed ObservedList.
		return new ListMoveEvent<E>(list,to,from);
	}

	public String getDescription() {
		return "Moving "+list.get(to);
	}
}
